<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">

        //1.   让爷爷拉二胡，让爸爸弹琴     
        // function Grand() {}  //爷爷
        // function Parent() {} //爸爸
        // Grand.prototype.tskill = '拉二胡';
        
        // var grand = new Grand();

        // // Parent.prototype = grand;
        // var parent = new Parent();
        // Parent.prototype.tskill = '弹琴';

        // console.log(parent.tskill);
        // console.log(grand.tskill);


        
        //2.
        
 function Test(){
       this.name = name;
       this.age = age;
  }
   obj = {}

    //分别使用call，apply为obj添加name，age属性
    

        //   Test.call(obj,name='张三',age=15);
        // Test.apply(obj,[name = '张三',age = 16]);
        //      console.log(obj);

    //3.
    //实现陈鹏买车，其中有sayHi方法，功能:打印'陈鹏买了一辆红色的2.0宝马车'
    // function sayHi(name,car,color) {
    //      this.name=name
    //      this.car=car
    //      this.color=color
        
    //     } 
    //     sayHi('陈鹏','2.0宝马车','红色')
    //     console.log(name+'买了一辆'+color+'的'+car);


    //4.父类Shape （属性有:name,length,width,方法有:Intro 我是XX形）

    //子类： Circle(属性有:r)

    //分别使用 原型链继承 构造函数继承 圣杯继承


    //原型链继承
    // function Shape() { }
    //     function Circle() { }
    //     Shape.prototype.name = 'dog'
    //     var shape = new Shape();
    //     Circle.prototype = shape;
    //     var circle = new Circle();
    //     circle.__proto__.r = '18';
    //     console.log(circle.r);

    //构造函数继承
        // function Shape(name,length,width){
        //     this.name = name;
        //     this.length = length;
        //     this.width = width;
        //     this.Intro = function(){
        //         console.log(this.name);
        //     } 
        // }
        // function Circle(r,name){
        //     Shape.call(this,name);
        //     this.r = r;
        // }
        // var circle = new Circle(1,'圆形');
        // circle.Intro();

        //圣杯继承
        // function Shape(){};
        // Shape.prototype.Intro = function(){
        //     console.log(this.name);
        // }
        // function Circle(){};
        // function inherit(Target,Origin){
        //     function F(){};
        //     F.prototype = Origin.prototype;
        //     Target.prototype = new F();
        //     Target.prototype.constructor = Target;
        //     Target.prototype.uber = Origin;
        // }
        // inherit(Circle,Shape);
        // var circle = new Circle();
        // circle.name = '圆形'
        // circle.Intro();
    </script>
</body>
</html>